
public class Bisseccao {
	
	public static double Modulo(double x){
		if(x < 0){
			x*=-1;
		}
		
		return x;
	}
	
	public static double[] calcular(double[] intervalo, Function func, double CP){
		double[] resp = new double[2];
		double med;
		
		do{
			med = (intervalo[0] + intervalo[1])/2;
			
			if(func.CalcFun(med)* func.CalcFun(intervalo[0]) > 0){
				intervalo[0] = med;
			}else if(func.CalcFun(med) == 0){
				intervalo[0] = intervalo[1] = med;
			}else{
				intervalo[1] = med;
			}
			
		}while(Modulo(func.CalcFun(med)) < CP);
		
		return resp;
	}
	
}
